﻿<!-- Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information. -->
<Page
    x:Class="Weathr.DirectXPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Weathr"
    xmlns:common="using:Weathr.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>
        <!-- Style for logging messages -->
        <Style x:Key="LogTextStyle" BasedOn="{StaticResource BaseTextBlockStyle}" TargetType="TextBlock">
            <Setter Property="FontFamily" Value="Courier New"/>
            <Setter Property="FontSize" Value="12"/>
        </Style>

        <local:LogMessageToColorConverter x:Key="LogMessageToColorConverter"/>
        <common:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>

        <!-- Data sources for logging messages -->
        <CollectionViewSource x:Name="LogMessagesCVS"/>
        <CollectionViewSource x:Name="ActionMessagesCVS"/>
    </Page.Resources>

    <SwapChainPanel x:Name="swapChainPanel">
        <Canvas>
            <StackPanel Canvas.Left="15" Canvas.Top="126">
                <!-- Logging messages -->
                <Border BorderThickness="1" BorderBrush="#33333333" Background="#22222222">
                    <ItemsControl ItemsSource="{Binding Source={StaticResource LogMessagesCVS}}" Visibility="{Binding ShowDebugOutput, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel/>
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Text}" Style="{StaticResource LogTextStyle}" Foreground="{Binding Converter={StaticResource LogMessageToColorConverter}}"/>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </Border>

                <!-- Async action messages -->
                <Border Margin="0,10,0,0" BorderThickness="1" BorderBrush="#44444444" Background="#22222222">
                    <ItemsControl ItemsSource="{Binding Source={StaticResource ActionMessagesCVS}}" Visibility="{Binding ShowDebugOutput, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel/>
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Text}" Style="{StaticResource LogTextStyle}" Foreground="{Binding Converter={StaticResource LogMessageToColorConverter}}"/>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </Border>
            </StackPanel>
        </Canvas>
    </SwapChainPanel>
</Page>
